.class Lcom/ryg/utils/SoLibManager$CopySoTask;
.super Ljava/lang/Object;

# interfaces
.implements Ljava/lang/Runnable;


# instance fields
.field private mContext:Landroid/content/Context;

.field private mLastModityTime:J

.field private mSoFileName:Ljava/lang/String;

.field private mZipEntry:Ljava/util/zip/ZipEntry;

.field private mZipFile:Ljava/util/zip/ZipFile;

.field final synthetic this$0:Lcom/ryg/utils/SoLibManager;


# direct methods
.method constructor <init>(Lcom/ryg/utils/SoLibManager;Landroid/content/Context;Ljava/util/zip/ZipFile;Ljava/util/zip/ZipEntry;J)V
    .locals 1

    iput-object p1, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->this$0:Lcom/ryg/utils/SoLibManager;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    iput-object p3, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mZipFile:Ljava/util/zip/ZipFile;

    iput-object p2, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mContext:Landroid/content/Context;

    iput-object p4, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mZipEntry:Ljava/util/zip/ZipEntry;

    invoke-virtual {p4}, Ljava/util/zip/ZipEntry;->getName()Ljava/lang/String;

    move-result-object v0

    invoke-direct {p0, v0}, Lcom/ryg/utils/SoLibManager$CopySoTask;->parseSoFileName(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mSoFileName:Ljava/lang/String;

    iput-wide p5, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mLastModityTime:J

    return-void
.end method

.method private getAvailableSize(Ljava/io/InputStream;)I
    .locals 1

    if-nez p1, :cond_1

    const/4 v0, 0x0

    :cond_0
    :goto_0
    return v0

    :cond_1
    invoke-virtual {p1}, Ljava/io/InputStream;->available()I

    move-result v0

    if-gtz v0, :cond_0

    const/16 v0, 0x400

    goto :goto_0
.end method

.method private final parseSoFileName(Ljava/lang/String;)Ljava/lang/String;
    .locals 1

    const-string/jumbo v0, "/"

    invoke-virtual {p1, v0}, Ljava/lang/String;->lastIndexOf(Ljava/lang/String;)I

    move-result v0

    add-int/lit8 v0, v0, 0x1

    invoke-virtual {p1, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method private writeSoFile2LibDir()V
    .locals 5

    iget-object v0, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mZipFile:Ljava/util/zip/ZipFile;

    iget-object v1, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mZipEntry:Ljava/util/zip/ZipEntry;

    invoke-virtual {v0, v1}, Ljava/util/zip/ZipFile;->getInputStream(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream;

    move-result-object v0

    new-instance v1, Ljava/io/FileOutputStream;

    new-instance v2, Ljava/io/File;

    # getter for: Lcom/ryg/utils/SoLibManager;->sNativeLibDir:Ljava/lang/String;
    invoke-static {}, Lcom/ryg/utils/SoLibManager;->access$000()Ljava/lang/String;

    move-result-object v3

    iget-object v4, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mSoFileName:Ljava/lang/String;

    invoke-direct {v2, v3, v4}, Ljava/io/File;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-direct {v1, v2}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    invoke-virtual {p0, v0, v1}, Lcom/ryg/utils/SoLibManager$CopySoTask;->copy(Ljava/io/InputStream;Ljava/io/OutputStream;)V

    iget-object v0, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mZipFile:Ljava/util/zip/ZipFile;

    invoke-virtual {v0}, Ljava/util/zip/ZipFile;->close()V

    return-void
.end method


# virtual methods
.method public copy(Ljava/io/InputStream;Ljava/io/OutputStream;)V
    .locals 7

    const/4 v6, 0x0

    if-eqz p1, :cond_0

    if-nez p2, :cond_1

    :cond_0
    :goto_0
    return-void

    :cond_1
    new-instance v0, Ljava/io/BufferedInputStream;

    invoke-direct {v0, p1}, Ljava/io/BufferedInputStream;-><init>(Ljava/io/InputStream;)V

    new-instance v1, Ljava/io/BufferedOutputStream;

    invoke-direct {v1, p2}, Ljava/io/BufferedOutputStream;-><init>(Ljava/io/OutputStream;)V

    invoke-direct {p0, v0}, Lcom/ryg/utils/SoLibManager$CopySoTask;->getAvailableSize(Ljava/io/InputStream;)I

    move-result v2

    new-array v3, v2, [B

    :goto_1
    invoke-virtual {v0, v3, v6, v2}, Ljava/io/BufferedInputStream;->read([BII)I

    move-result v4

    const/4 v5, -0x1

    if-eq v4, v5, :cond_2

    invoke-virtual {v1, v3, v6, v4}, Ljava/io/BufferedOutputStream;->write([BII)V

    goto :goto_1

    :cond_2
    invoke-virtual {v1}, Ljava/io/BufferedOutputStream;->flush()V

    invoke-virtual {v1}, Ljava/io/BufferedOutputStream;->close()V

    invoke-virtual {v0}, Ljava/io/BufferedInputStream;->close()V

    goto :goto_0
.end method

.method public run()V
    .locals 4

    :try_start_0
    invoke-direct {p0}, Lcom/ryg/utils/SoLibManager$CopySoTask;->writeSoFile2LibDir()V

    iget-object v0, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mContext:Landroid/content/Context;

    iget-object v1, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mZipEntry:Ljava/util/zip/ZipEntry;

    invoke-virtual {v1}, Ljava/util/zip/ZipEntry;->getName()Ljava/lang/String;

    move-result-object v1

    iget-wide v2, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mLastModityTime:J

    invoke-static {v0, v1, v2, v3}, Lcom/ryg/utils/DLConfigs;->setSoLastModifiedTime(Landroid/content/Context;Ljava/lang/String;J)V

    # getter for: Lcom/ryg/utils/SoLibManager;->TAG:Ljava/lang/String;
    invoke-static {}, Lcom/ryg/utils/SoLibManager;->access$100()Ljava/lang/String;

    move-result-object v0

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v2, "copy so lib success: "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-object v2, p0, Lcom/ryg/utils/SoLibManager$CopySoTask;->mZipEntry:Ljava/util/zip/ZipEntry;

    invoke-virtual {v2}, Ljava/util/zip/ZipEntry;->getName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    :goto_0
    return-void

    :catch_0
    move-exception v0

    # getter for: Lcom/ryg/utils/SoLibManager;->TAG:Ljava/lang/String;
    invoke-static {}, Lcom/ryg/utils/SoLibManager;->access$100()Ljava/lang/String;

    move-result-object v1

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v3, "copy so lib failed: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v0}, Ljava/io/IOException;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_0
.end method
